package com.wonderful.mall.order.listener;

import com.rabbitmq.client.Channel;
import com.wonderful.common.to.mq.SeckillOrderTo;
import com.wonderful.mall.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
@Slf4j
@Component
@RabbitListener(queues = "order.seckill.order.queue")
public class OrderSeckillListener {
    @Resource
    OrderService orderService;
    @RabbitHandler
    public void listener(SeckillOrderTo to, Channel channel, Message message) throws IOException {
        log.info("创建秒杀单详细信息");
        orderService.createSeckillOrder(to);
    }
}
